home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / mweb / MWEB Utils / ws295sdk.exe / Ws2sdkzp.exe / SAMPLES / LAYERED / DPROVIDE.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-06-06  |  72.5 KB  |  2,752 lines

  1. /*++
  2.  
  3.  
  4.      Copyright c 1996 Intel Corporation
  5.      All Rights Reserved
  6.  
  7.      Permission is granted to use, copy and distribute this software and
  8.      its documentation for any purpose and without fee, provided, that
  9.      the above copyright notice and this statement appear in all copies.
  10.      Intel makes no representations about the suitability of this
  11.      software for any purpose.  This software is provided "AS IS."
  12.  
  13.      Intel specifically disclaims all warranties, express or implied,
  14.      and all liability, including consequential and other indirect
  15.      damages, for the use of this software, including liability for
  16.      infringement of any proprietary rights, and including the
  17.      warranties of merchantability and fitness for a particular purpose.
  18.      Intel does not assume any responsibility for any errors which may
  19.      appear in this software nor any responsibility to update it.
  20.  
  21.  
  22. Module Name:
  23.  
  24.         dprovide.h
  25.  
  26. Abstract:
  27.  
  28.         This module defines the layered service provider class dprovider along
  29.         with its methods.
  30.  
  31. --*/
  32. #ifndef _DPROVIDER_
  33. #define _DPROVIDER_
  34.  
  35.  
  36. #include <winsock2.h>
  37. #include <ws2spi.h>
  38. #include <mswsock.h>
  39. #include "llist.h"
  40. #include "dthook.h"
  41.  
  42.  
  43. BOOL
  44. PASCAL FAR
  45. WSPTransmitFile (
  46.     IN SOCKET hSocket,
  47.     IN HANDLE hFile,
  48.     IN DWORD nNumberOfBytesToWrite,
  49.     IN DWORD nNumberOfBytesPerSend,
  50.     IN LPOVERLAPPED lpOverlapped,
  51.     IN LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers,
  52.     IN DWORD dwReserved
  53.     );
  54.  
  55. BOOL
  56. PASCAL FAR
  57. WSPAcceptEx (
  58.     IN SOCKET sListenSocket,
  59.     IN SOCKET sAcceptSocket,
  60.     IN PVOID lpOutputBuffer,
  61.     IN DWORD dwReceiveDataLength,
  62.     IN DWORD dwLocalAddressLength,
  63.     IN DWORD dwRemoteAddressLength,
  64.     OUT LPDWORD lpdwBytesReceived,
  65.     IN LPOVERLAPPED lpOverlapped
  66.     );
  67.  
  68.  
  69.  
  70. class DPROVIDER {
  71.  
  72.   public:
  73.  
  74.     DPROVIDER();
  75.  
  76.     ~DPROVIDER();
  77.  
  78.     INT
  79.     Initialize(
  80.         IN PWCHAR lpszLibFile,
  81.         IN LPWSAPROTOCOL_INFOW lpProtocolInfo);
  82.  
  83.     SOCKET
  84.     WSPAccept(
  85.         IN SOCKET s,
  86.         OUT struct sockaddr FAR *addr,
  87.         OUT INT FAR *addrlen,
  88.         IN LPCONDITIONPROC lpfnCondition,
  89.         IN DWORD dwCallbackData,
  90.         OUT INT FAR *lpErrno);
  91.  
  92.     INT
  93.     WSPAddressToString(
  94.         IN     LPSOCKADDR lpsaAddress,
  95.         IN     DWORD dwAddressLength,
  96.         IN     LPWSAPROTOCOL_INFOW lpProtocolInfo,
  97.         OUT    LPWSTR lpszAddressString,
  98.         IN OUT LPDWORD lpdwAddressStringLength,
  99.         OUT    LPINT lpErrno );
  100.  
  101.     INT
  102.     WSPAsyncSelect(
  103.         IN SOCKET s,
  104.         IN HWND hWnd,
  105.         IN unsigned int wMsg,
  106.         IN long lEvent,
  107.         OUT INT FAR *lpErrno);
  108.  
  109.     INT
  110.     WSPBind(
  111.         IN SOCKET s,
  112.         IN const struct sockaddr FAR *name,
  113.         IN INT namelen,
  114.         OUT INT FAR *lpErrno);
  115.  
  116.     INT
  117.     WSPCancelBlockingCall(
  118.         OUT INT FAR *lpErrno);
  119.  
  120.     INT
  121.     WSPCleanup(
  122.         OUT INT FAR *lpErrno);
  123.  
  124.     INT
  125.     WSPCloseSocket(
  126.         IN SOCKET s,
  127.         OUT INT FAR *lpErrno);
  128.  
  129.     INT
  130.     WSPConnect(
  131.         IN SOCKET s,
  132.         IN const struct sockaddr FAR *name,
  133.         IN INT namelen,
  134.         IN LPWSABUF lpCallerData,
  135.         IN LPWSABUF lpCalleeData,
  136.         IN LPQOS lpSQOS,
  137.         IN LPQOS lpGQOS,
  138.         OUT INT FAR *lpErrno);
  139.  
  140.     INT
  141.     WSPDuplicateSocket(
  142.         IN SOCKET s,
  143.         IN DWORD dwProcessID,
  144.         IN LPWSAPROTOCOL_INFOW lpProtocolInfo,
  145.         OUT INT FAR *lpErrno);
  146.  
  147.     INT
  148.     WSPEnumNetworkEvents(
  149.         IN SOCKET s,
  150.         OUT WSAEVENT hEventObject,
  151.         OUT LPWSANETWORKEVENTS lpNetworkEvents,
  152.         OUT INT FAR *lpErrno);
  153.  
  154.     INT
  155.     WSPEventSelect(
  156.         IN SOCKET s,
  157.         IN OUT WSAEVENT hEventObject,
  158.         IN long lNetworkEvents,
  159.         OUT INT FAR *lpErrno);
  160.  
  161.     INT
  162.     WSPGetOverlappedResult(
  163.         IN SOCKET s,
  164.         IN LPWSAOVERLAPPED lpOverlapped,
  165.         IN LPDWORD lpcbTransfer,
  166.         IN BOOL fWait,
  167.         OUT LPDWORD lpdwFlags,
  168.         OUT INT FAR *lpErrno);
  169.  
  170.     INT
  171.     WSPGetPeerName(
  172.         IN SOCKET s,
  173.         OUT struct sockaddr FAR *name,
  174.         OUT INT FAR *namelen,
  175.         OUT INT FAR *lpErrno);
  176.  
  177.     INT
  178.     WSPGetQOSByName(
  179.         IN SOCKET s,
  180.         IN LPWSABUF lpQOSName,
  181.         IN LPQOS lpQOS,
  182.         OUT INT FAR *lpErrno);
  183.  
  184.     INT
  185.     WSPGetSockName(
  186.         IN SOCKET s,
  187.         OUT struct sockaddr FAR *name,
  188.         OUT INT FAR *namelen,
  189.         OUT INT FAR *lpErrno);
  190.  
  191.     INT
  192.     WSPGetSockOpt(
  193.         IN SOCKET s,
  194.         IN INT level,
  195.         IN INT optname,
  196.         OUT char FAR *optval,
  197.         OUT INT FAR *optlen,
  198.         OUT INT FAR *lpErrno);
  199.  
  200.     INT
  201.     WSPIoctl(
  202.         IN SOCKET s,
  203.         IN DWORD dwIoControlCode,
  204.         IN LPVOID lpvInBuffer,
  205.         IN DWORD cbInBuffer,
  206.         IN LPVOID lpvOutBuffer,
  207.         IN DWORD cbOutBuffer,
  208.         IN LPDWORD lpcbBytesReturned,
  209.         IN LPWSAOVERLAPPED lpOverlapped,
  210.         IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine,
  211.         IN LPWSATHREADID lpThreadId,
  212.         OUT INT FAR *lpErrno);
  213.  
  214.     INT
  215.     WSPJoinLeaf(
  216.         IN SOCKET s,
  217.         IN const struct sockaddr FAR *name,
  218.         IN INT namelen,
  219.         IN LPWSABUF lpCallerData,
  220.         IN LPWSABUF lpCalleeData,
  221.         IN LPQOS lpSQOS,
  222.         IN LPQOS lpGQOS,
  223.         IN DWORD dwFlags,
  224.         OUT INT FAR *lpErrno);
  225.  
  226.     INT
  227.     WSPListen(
  228.         IN SOCKET s,
  229.         IN INT backlog,
  230.         OUT INT FAR *lpErrno);
  231.  
  232.  
  233.     INT
  234.     WSPRecv(
  235.         IN SOCKET s,
  236.         IN LPWSABUF lpBuffers,
  237.         IN DWORD dwBufferCount,
  238.         IN LPDWORD lpNumberOfBytesRecvd,
  239.         IN OUT LPDWORD lpFlags,
  240.         IN LPWSAOVERLAPPED lpOverlapped,
  241.         IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine,
  242.         IN LPWSATHREADID lpThreadId,
  243.         OUT INT FAR *lpErrno);
  244.  
  245.  
  246.     INT
  247.     WSPRecvDisconnect(
  248.         IN SOCKET s,
  249.         IN LPWSABUF lpInboundDisconnectData,
  250.         OUT INT FAR *lpErrno);
  251.  
  252.  
  253.     INT
  254.     WSPRecvFrom(
  255.         IN SOCKET s,
  256.         IN LPWSABUF lpBuffers,
  257.         IN DWORD dwBufferCount,
  258.         IN LPDWORD lpNumberOfBytesRecvd,
  259.         IN OUT LPDWORD lpFlags,
  260.         OUT  struct sockaddr FAR *  lpFrom,
  261.         IN LPINT lpFromlen,
  262.         IN LPWSAOVERLAPPED lpOverlapped,
  263.         IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine,
  264.         IN LPWSATHREADID lpThreadId,
  265.         OUT INT FAR *lpErrno);
  266.  
  267.  
  268.     INT
  269.     WSPSelect(
  270.         IN INT nfds,
  271.         IN OUT fd_set FAR *readfds,
  272.         IN OUT fd_set FAR *writefds,
  273.         IN OUT fd_set FAR *exceptfds,
  274.         IN const struct timeval FAR *timeout,
  275.         OUT INT FAR *lpErrno);
  276.  
  277.  
  278.     INT
  279.     WSPSend(
  280.         IN SOCKET s,
  281.         IN LPWSABUF lpBuffers,
  282.         IN DWORD dwBufferCount,
  283.         OUT LPDWORD lpNumberOfBytesSent,
  284.         IN DWORD dwFlags,
  285.         IN LPWSAOVERLAPPED lpOverlapped,
  286.         IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine,
  287.         IN LPWSATHREADID lpThreadId,
  288.         OUT INT FAR *lpErrno);
  289.  
  290.     INT
  291.     WSPSendDisconnect(
  292.         IN SOCKET s,
  293.         IN LPWSABUF lpOutboundDisconnectData,
  294.         OUT INT FAR *lpErrno);
  295.  
  296.     INT
  297.     WSPSendTo(
  298.         IN SOCKET s,
  299.         IN LPWSABUF lpBuffers,
  300.         IN DWORD dbBufferCount,
  301.         IN LPDWORD lpNumberOfBytesSent,
  302.         IN DWORD dwFlags,
  303.         IN const struct sockaddr FAR * lpTo,
  304.         IN INT iTolen,
  305.         IN LPWSAOVERLAPPED lpOverlapped,
  306.         IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine,
  307.         IN LPWSATHREADID lpThreadId,
  308.         OUT INT FAR *lpErrno);
  309.  
  310.     INT
  311.     WSPSetSockOpt(
  312.         IN SOCKET s,
  313.         IN INT level,
  314.         IN INT optname,
  315.         IN const char FAR *optval,
  316.         IN INT optlen,
  317.         OUT INT FAR *lpErrno);
  318.  
  319.     INT
  320.     WSPShutdown(
  321.         IN SOCKET s,
  322.         IN INT how,
  323.         OUT INT FAR *lpErrno);
  324.  
  325.     INT
  326.     WSPSocket(
  327.         IN int af,
  328.         IN int type,
  329.         IN int protocol,
  330.         IN LPWSAPROTOCOL_INFOW lpProtocolInfo,
  331.         IN GROUP g,
  332.         IN DWORD dwFlags,
  333.         OUT INT FAR *lpErrno);
  334.  
  335.     INT
  336.     WSPStringToAddress(
  337.         IN     LPWSTR AddressString,
  338.         IN     INT AddressFamily,
  339.         IN     LPWSAPROTOCOL_INFOW lpProtocolInfo,
  340.         OUT    LPSOCKADDR lpAddress,
  341.         IN OUT LPINT lpAddressLength,
  342.         IN OUT LPINT lpErrno );
  343.  
  344.     INT
  345.     TransmitFile (
  346.         IN SOCKET hSocket,
  347.         IN HANDLE hFile,
  348.         IN DWORD nNumberOfBytesToWrite,
  349.         IN DWORD nNumberOfBytesPerSend,
  350.         IN LPOVERLAPPED lpOverlapped,
  351.         IN LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers,
  352.         IN DWORD dwReserved,
  353.         OUT LPINT lpErrno
  354.         );
  355.  
  356.     INT
  357.     AcceptEx (
  358.         IN SOCKET sListenSocket,
  359.         IN SOCKET sAcceptSocket,
  360.         IN PVOID lpOutputBuffer,
  361.         IN DWORD dwReceiveDataLength,
  362.         IN DWORD dwLocalAddressLength,
  363.         IN DWORD dwRemoteAddressLength,
  364.         OUT LPDWORD lpdwBytesReceived,
  365.         IN LPOVERLAPPED lpOverlapped,
  366.         OUT LPINT lpErrno
  367.         );
  368.  
  369.     INT
  370.     InterceptExtensions (
  371.         IN LPVOID        lpvInBuffer,
  372.         OUT LPVOID        lpvOutBuffer,
  373.         OUT LPINT        lpErrno
  374.         );
  375.  
  376.   private:
  377.     // Variables
  378.     LPWSPPROC_TABLE      m_proctable;
  379.     BOOL              m_extensions_initialized;
  380.     LPFN_TRANSMITFILE m_transmitfile;
  381.     LPFN_ACCEPTEX      m_acceptex;
  382.     HINSTANCE         m_library_handle;
  383.     LPSTR            m_lib_name;
  384. };
  385.  
  386.  
  387.  
  388. inline SOCKET
  389. DPROVIDER::WSPAccept(
  390.     IN SOCKET s,
  391.     OUT struct sockaddr FAR *addr,
  392.     OUT INT FAR *addrlen,
  393.     IN LPCONDITIONPROC lpfnCondition,
  394.     IN DWORD dwCallbackData,
  395.     OUT INT FAR *lpErrno
  396.     )
  397. /*++
  398. Routine Description:
  399.  
  400.     Conditionally  accept a connection based on the return value of a condition
  401.     function, and optionally create and/or join a socket group.
  402.  
  403. Arguments:
  404.  
  405.     s              - A  descriptor  identiying  a socket which is listening for
  406.                      connections after a WSPListen().
  407.  
  408.     addr           - An optional pointer to a buffer which receives the address
  409.                      of   the  connecting  entity,  as  known  to  the  service
  410.                      provider.   The  exact  format  of  the  addr arguement is
  411.                      determined  by  the  address  family  established when the
  412.                      socket was created.
  413.  
  414.     addrlen        - An  optional  pointer  to  an  integer  which contains the
  415.                      length of the address addr.
  416.  
  417.     lpfnCondition  - The  procedure  instance address of an optional, WinSock 2
  418.                      client  supplied  condition  function  which  will make an
  419.                      accept/reject  decision  based  on  the caller information
  420.                      passed  in  as  parameters,  and optionally creaetd and/or
  421.                      join  a  socket group by assigning an appropriate value to
  422.                      the result parameter of this function.
  423.  
  424.     dwCallbackData - Callback data to be passed back to the WinSock 2 client as
  425.                      a  condition  function  parameter.   This parameter is not
  426.                      interpreted by the service provider.
  427.  
  428.     lpErrno        - A pointer to the error code.
  429.  
  430. Return Value:
  431.  
  432.     If  no  error occurs, WSPAccept() returns a value of type SOCKET which is a
  433.     descriptor  for  the accepted socket.  Otherwise, a value of INVALID_SOCKET
  434.     is returned, and a specific error code is available in lpErrno.
  435.  
  436. --*/
  437. {
  438.     SOCKET ReturnValue;
  439.  
  440.     if (PREAPINOTIFY(( DTCODE_WSPAccept,
  441.                        &ReturnValue,
  442.                        m_lib_name,
  443.                        &s,
  444.                        &addr,
  445.                        &addrlen,
  446.                        &lpfnCondition,
  447.                        &dwCallbackData,
  448.                        &lpErrno)) ) {
  449.         return(ReturnValue);
  450.     }
  451.  
  452.     ReturnValue = m_proctable->lpWSPAccept(
  453.         s,
  454.         addr,
  455.         addrlen,
  456.         lpfnCondition,
  457.         dwCallbackData,
  458.         lpErrno);
  459.  
  460.     POSTAPINOTIFY(( DTCODE_WSPAccept,
  461.                     &ReturnValue,
  462.                     m_lib_name,
  463.                     &s,
  464.                     &addr,
  465.                     &addrlen,
  466.                     &lpfnCondition,
  467.                     &dwCallbackData,
  468.                     &lpErrno));
  469.  
  470.     return(ReturnValue);
  471.  
  472. }
  473.  
  474.  
  475.  
  476.  
  477. inline INT
  478. DPROVIDER::WSPAddressToString(
  479.     IN     LPSOCKADDR lpsaAddress,
  480.     IN     DWORD dwAddressLength,
  481.     IN     LPWSAPROTOCOL_INFOW lpProtocolInfo,
  482.     OUT    LPWSTR lpszAddressString,
  483.     IN OUT LPDWORD lpdwAddressStringLength,
  484.     OUT    LPINT lpErrno )
  485. /*++
  486.  
  487. Routine Description:
  488.  
  489.     WSPAddressToString() converts a SOCKADDR structure into a human-readable
  490.     string representation of the address.  This is intended to be used mainly
  491.     for display purposes. If the caller wishes the translation to be done by a
  492.     particular provider, it should supply the corresponding WSAPROTOCOL_INFO
  493.     struct in the lpProtocolInfo parameter.
  494.  
  495. Arguments:
  496.  
  497.     lpsaAddress - points to a SOCKADDR structure to translate into a string.
  498.  
  499.     dwAddressLength - the length of the Address SOCKADDR.
  500.  
  501.     lpProtocolInfo - (optional) the WSAPROTOCOL_INFO struct for a particular
  502.                      provider.
  503.  
  504.     lpszAddressString - a buffer which receives the human-readable address
  505.                         string.
  506.  
  507.     lpdwAddressStringLength - on input, the length of the AddressString buffer.
  508.                               On output, returns the length of  the string
  509.                               actually copied into the buffer.
  510.  
  511. Return Value:
  512.  
  513.     The return value is 0 if the operation was successful.  Otherwise the value
  514.     SOCKET_ERROR is returned
  515. --*/
  516. {
  517.      INT ReturnValue;
  518.  
  519. //      if (PREAPINOTIFY(( DTCODE_WSPAddressToString,
  520. //                         &ReturnValue,
  521. //                         m_lib_name,
  522. //                         &lpsaAddress,
  523. //                         &dwAddressLength,
  524. //                         &lpProtocolInfo,
  525. //                         &lpszAddressString,
  526. //                         &lpdwAddressStringLength,
  527. //                         &lpErrno)) ) {
  528. //          return(ReturnValue);
  529. //      }
  530.  
  531.     ReturnValue = m_proctable->lpWSPAddressToString(
  532.         lpsaAddress,
  533.         dwAddressLength,
  534.         lpProtocolInfo,
  535.         lpszAddressString,
  536.         lpdwAddressStringLength,
  537.         lpErrno);
  538.  
  539.  
  540. //      POSTAPINOTIFY(DTCODE_WSPAddressToString,
  541. //                    &ReturnValue,
  542. //                    m_lib_name,
  543. //                    &lpsaAddress,
  544. //                    &dwAddressLength,
  545. //                    &lpProtocolInfo,
  546. //                    &lpszAddressString,
  547. //                    &lpdwAddressStringLength,
  548. //                    &lpErrno)));
  549.  
  550.     return(ReturnValue);
  551. }
  552.  
  553.  
  554.  
  555.  
  556.  
  557. inline INT
  558. DPROVIDER::WSPAsyncSelect(
  559.     IN SOCKET s,
  560.     IN HWND hWnd,
  561.     IN unsigned int wMsg,
  562.     IN long lEvent,
  563.     OUT INT FAR *lpErrno
  564.     )
  565. /*++
  566. Routine Description:
  567.  
  568.     Request  Windows  message-based  event notification of network events for a
  569.     socket.
  570.  
  571. Arguments:
  572.  
  573.     s       - A  descriptor identiying a socket for which event notification is
  574.               required.
  575.  
  576.     hWnd    - A  handle  identifying  the window which should receive a message
  577.               when a network event occurs.
  578.  
  579.     wMsg    - The message to be sent when a network event occurs.
  580.  
  581.     lEvent  - bitmask  which specifies a combination of network events in which
  582.               the WinSock client is interested.
  583.  
  584.     lpErrno - A pointer to the error code.
  585.  
  586. Return Value:
  587.  
  588.     The  return  value  is 0 if the WinSock client's declaration of interest in
  589.     the  netowrk event set was successful.  Otherwise the value SOCKET_ERROR is
  590.     returned, and a specific error code is available in lpErrno.
  591.  
  592. --*/
  593. {
  594.     INT ReturnValue;
  595.  
  596.     if (PREAPINOTIFY(( DTCODE_WSPAsyncSelect,
  597.                        &ReturnValue,
  598.                        m_lib_name,
  599.                        &s,
  600.                        &hWnd,
  601.                        &wMsg,
  602.                        &lEvent,
  603.                        &lpErrno)) ) {
  604.         return(ReturnValue);
  605.     }
  606.  
  607.     ReturnValue = m_proctable->lpWSPAsyncSelect(
  608.         s,
  609.         hWnd,
  610.         wMsg,
  611.         lEvent,
  612.         lpErrno);
  613.  
  614.     POSTAPINOTIFY(( DTCODE_WSPAsyncSelect,
  615.                     &ReturnValue,
  616.                     m_lib_name,
  617.                     &s,
  618.                     &hWnd,
  619.                     &wMsg,
  620.                     &lEvent,
  621.                     &lpErrno));
  622.  
  623.     return(ReturnValue);
  624.  
  625. }
  626.  
  627.  
  628.  
  629. inline INT
  630. DPROVIDER::WSPBind(
  631.     IN SOCKET s,
  632.     IN const struct sockaddr FAR *name,
  633.     IN INT namelen,
  634.     OUT INT FAR *lpErrno
  635.     )
  636. /*++
  637. Routine Description:
  638.  
  639.     Associate a local address (i.e. name) with a socket.
  640.  
  641. Arguments:
  642.  
  643.     s       - A descriptor identifying an unbound socket.
  644.  
  645.     name    - The  address  to assign to the socket.  The sockaddr structure is
  646.               defined as follows:
  647.  
  648.               struct sockaddr {
  649.                   u_short sa_family;
  650.                   char    sa_data[14];
  651.               };
  652.  
  653.               Except  for  the sa_family field,
  654. sockaddr contents are epxressed
  655.               in network byte order.
  656.  
  657.     namelen - The length of the name.
  658.  
  659.     lpErrno - A pointer to the error code.
  660.  
  661. Return Value:
  662.  
  663.     If   no   erro   occurs,  WSPBind()  returns  0.   Otherwise, it  returns
  664.     SOCKET_ERROR, and a specific error code is available in lpErrno.
  665.  
  666. --*/
  667. {
  668.     INT ReturnValue;
  669.     if (PREAPINOTIFY(( DTCODE_WSPBind,
  670.                        &ReturnValue,
  671.                        m_lib_name,
  672.                        &s,
  673.                        &name,
  674.                        &namelen,
  675.                        &lpErrno)) ) {
  676.  
  677.         return(ReturnValue);
  678.     }
  679.  
  680.     ReturnValue = m_proctable->lpWSPBind(
  681.         s,
  682.         name,
  683.         namelen,
  684.         lpErrno);
  685.  
  686.     POSTAPINOTIFY(( DTCODE_WSPBind,
  687.                     &ReturnValue,
  688.                     m_lib_name,
  689.                     &s,
  690.                     &name,
  691.                     &namelen,
  692.                     &lpErrno));
  693.  
  694.     return(ReturnValue);
  695.  
  696. }
  697.  
  698.  
  699.  
  700. inline INT
  701. DPROVIDER::WSPCancelBlockingCall(OUT INT FAR *lpErrno)
  702. /*++
  703. Routine Description:
  704.  
  705.     Cancel a blocking call which is currently in progress.
  706.  
  707. Arguments:
  708.  
  709.     lpErrno - A pointer to the error code.
  710.  
  711. Return Value:
  712.  
  713.     The  value  returned  by  WSPCancelBlockingCall() is 0 if the operation was
  714.     successfully canceled.  Otherwise the value SOCKET_ERROR is returned,
  715. and a
  716.     specific error code is available in lpErrno.
  717.  
  718. --*/
  719. {
  720.     INT ReturnValue;
  721.  
  722.     if (PREAPINOTIFY(( DTCODE_WSPCancelBlockingCall,
  723.                        &ReturnValue,
  724.                        m_lib_name,
  725.                        &lpErrno)) ) {
  726.         return(ReturnValue);
  727.     }
  728.  
  729.     ReturnValue = m_proctable->lpWSPCancelBlockingCall(
  730.         lpErrno);
  731.  
  732.     POSTAPINOTIFY(( DTCODE_WSPCancelBlockingCall,
  733.                     &ReturnValue,
  734.                     m_lib_name,
  735.                     &lpErrno));
  736.  
  737.     return(ReturnValue);
  738.  
  739. }
  740.  
  741.  
  742.  
  743. inline INT
  744. DPROVIDER::WSPCleanup(
  745.     OUT INT FAR *lpErrno
  746.     )
  747. /*++
  748. Routine Description:
  749.  
  750.     Terminate use of the WinSock service provider.
  751.  
  752. Arguments:
  753.  
  754.     lpErrno - A pointer to the error code.
  755.  
  756. Return Value:
  757.  
  758.     The  return  value  is  0 if the operation has been successfully initiated.
  759.     Otherwise  the  value SOCKET_ERROR is returned,
  760. and a specific error number
  761.     is available in lpErrno.
  762.  
  763. --*/
  764.  
  765. {
  766.     INT ReturnValue;
  767.  
  768.     if (PREAPINOTIFY(( DTCODE_WSPCleanup,
  769.                        &ReturnValue,
  770.                        m_lib_name,
  771.                        &lpErrno)) ) {
  772.         return(ReturnValue);
  773.     }
  774.  
  775.     ReturnValue = m_proctable->lpWSPCleanup(
  776.         lpErrno);
  777.  
  778.     POSTAPINOTIFY(( DTCODE_WSPCleanup,
  779.                     &ReturnValue,
  780.                     m_lib_name,
  781.                     &lpErrno));
  782.  
  783.     return(ReturnValue);
  784.  
  785. }
  786.  
  787.  
  788.  
  789. inline INT
  790. DPROVIDER::WSPCloseSocket(
  791.     IN SOCKET s,
  792.     OUT INT FAR *lpErrno
  793.     )
  794. /*++
  795. Routine Description:
  796.  
  797.     Close a socket.
  798.  
  799. Arguments:
  800.  
  801.     s       - A descriptor identifying a socket.
  802.  
  803.     lpErrno - A pointer to the error code.
  804.  
  805. Return Value:
  806.  
  807.     If  no  erro  occurs, WSPCloseSocket()  returns  0.  Otherwise, a value of
  808.     SOCKET_ERROR  is  returned,  and  a  specific  error  code  is available in
  809.     lpErrno.
  810.  
  811. --*/
  812. {
  813.     INT ReturnValue;
  814.  
  815.     if (PREAPINOTIFY(( DTCODE_WSPCloseSocket,
  816.                        &ReturnValue,
  817.                        m_lib_name,
  818.                        &s,
  819.                        &lpErrno)) ) {
  820.         return(ReturnValue);
  821.     }
  822.  
  823.     ReturnValue = m_proctable->lpWSPCloseSocket(
  824.         s,
  825.         lpErrno);
  826.  
  827.     POSTAPINOTIFY(( DTCODE_WSPCloseSocket,
  828.                     &ReturnValue,
  829.                     m_lib_name,
  830.                     &s,
  831.                     &lpErrno));
  832.  
  833.     return(ReturnValue);
  834.  
  835. }
  836.  
  837.  
  838.  
  839. inline INT
  840. DPROVIDER::WSPConnect(
  841.     IN SOCKET s,
  842.     IN const struct sockaddr FAR *name,
  843.     IN INT namelen,
  844.     IN LPWSABUF lpCallerData,
  845.     IN LPWSABUF lpCalleeData,
  846.     IN LPQOS lpSQOS,
  847.     IN LPQOS lpGQOS,
  848.     OUT INT FAR *lpErrno
  849.     )
  850. /*++
  851. Routine Description:
  852.  
  853.     Establish a connection to a peer,
  854. exchange connect data,
  855. and specify needed
  856.     quality of service based on the supplied flow spec.
  857.  
  858. Arguments:
  859.  
  860.     s            - A descriptor identifying an unconnected socket.
  861.  
  862.     name         - The name of the peer to which the socket is to be connected.
  863.  
  864.     namelen      - The length of the name.
  865.  
  866.     lpCallerData - A  pointer to the user data that is to be transferred to the
  867.                    peer during connection established.
  868.  
  869.     lpCalleeData - A pointer to a buffer into which may be copied any user data
  870.                    received from the peer during connection establishment.
  871.  
  872.     lpSQOS       - A  pointer  to  the  flow  specs  for socket s, one for each
  873.                    direction.
  874.  
  875.     lpGQOS       - A  pointer  to  the  flow  specs  for  the  socket group (if
  876.                    applicable).
  877.  
  878.     lpErrno      - A pointer to the error code.
  879.  
  880. Return Value:
  881.  
  882.     If  no  error  occurs, WSPConnect()  returns ERROR_SUCCESS.  Otherwise, it
  883.     returns SOCKET_ERROR, and a specific erro rcode is available in lpErrno.
  884.  
  885. --*/
  886. {
  887.     INT ReturnValue;
  888.  
  889.     if (PREAPINOTIFY(( DTCODE_WSPConnect,
  890.                        &ReturnValue,
  891.                        m_lib_name,
  892.                        &s,
  893.                        &name,
  894.                        &namelen,
  895.                        &lpCallerData,
  896.                        &lpCalleeData,
  897.                        &lpSQOS,
  898.                        &lpGQOS,
  899.                        &lpErrno)) ) {
  900.         return(ReturnValue);
  901.     }
  902.  
  903.     ReturnValue = m_proctable->lpWSPConnect(
  904.         s,
  905.         name,
  906.         namelen,
  907.         lpCallerData,
  908.         lpCalleeData,
  909.         lpSQOS,
  910.         lpGQOS,
  911.         lpErrno);
  912.  
  913.     POSTAPINOTIFY(( DTCODE_WSPConnect,
  914.                     &ReturnValue,
  915.                     m_lib_name,
  916.                     &s,
  917.                     &name,
  918.                     &namelen,
  919.                     &lpCallerData,
  920.                     &lpCalleeData,
  921.                     &lpSQOS,
  922.                     &lpGQOS,
  923.                     &lpErrno));
  924.  
  925.     return(ReturnValue);
  926.  
  927. }
  928.  
  929.  
  930.  
  931. inline INT
  932. DPROVIDER::WSPDuplicateSocket(
  933.     IN SOCKET s,
  934.     IN DWORD dwProcessID,
  935.     IN LPWSAPROTOCOL_INFOW lpProtocolInfo,
  936.     OUT INT FAR *lpErrno
  937.     )
  938. /*++
  939. Routine Description:
  940.  
  941.     descriptor for a shared socket.
  942.  
  943.  
  944. Arguments:
  945.  
  946.     s              - Specifies the local socket descriptor.
  947.  
  948.     dwProcessID    - Specifies  the  ID  of  the  target  process for which the
  949.                      shared socket will be used.
  950.  
  951.     lpProtocolInfo - A  pointer  to  a  buffer  allocated by the client that is
  952.                      large enough to contain a WSAPROTOCOL_INFOA struct.  The
  953.                      service  provider copies the protocol info struct contents
  954.                      to this buffer.
  955.  
  956.     lpErrno        - A pointer to the error code
  957.  
  958. Return Value:
  959.  
  960.     If  no  error  occurs, WPSDuplicateSocket()  returns zero.  Otherwise, the
  961.     value of SOCKET_ERROR is returned, and a specific error number is available
  962.     in lpErrno.
  963.  
  964. --*/
  965. {
  966.     INT ReturnValue;
  967.  
  968.     if (PREAPINOTIFY(( DTCODE_WSPDuplicateSocket,
  969.                        &ReturnValue,
  970.                        m_lib_name,
  971.                        &s,
  972.                        &dwProcessID,
  973.                        &lpProtocolInfo,
  974.                        &lpErrno)) ) {
  975.         return(ReturnValue);
  976.     }
  977.  
  978.     ReturnValue = m_proctable->lpWSPDuplicateSocket(
  979.         s,
  980.         dwProcessID,
  981.         lpProtocolInfo,
  982.         lpErrno);
  983.  
  984.     POSTAPINOTIFY(( DTCODE_WSPDuplicateSocket,
  985.                     &ReturnValue,
  986.                     m_lib_name,
  987.                     &s,
  988.                     &dwProcessID,
  989.                     &lpProtocolInfo,
  990.                     &lpErrno));
  991.  
  992.     return(ReturnValue);
  993.  
  994. }
  995.  
  996.  
  997.  
  998. inline INT
  999. DPROVIDER::WSPEnumNetworkEvents(
  1000.     IN SOCKET s,
  1001.     OUT WSAEVENT hEventObject,
  1002.     OUT LPWSANETWORKEVENTS lpNetworkEvents,
  1003.     OUT INT FAR *lpErrno
  1004.     )
  1005. /*++
  1006. Routine Description:
  1007.  
  1008.     Report occurrences of network events for the indicated socket.
  1009.  
  1010. Arguments:
  1011.  
  1012.     s               - A descriptor identifying the socket.
  1013.  
  1014.     hEventObject    - An optional handle identifying an associated event object
  1015.                       to be reset.
  1016.  
  1017.     lpNetworkEvents - A  pointer  to  a WSANETWORKEVENTS struct which is filled
  1018.                       with   a  record  of  occurred  network  events  and  any
  1019.                       associated error codes.
  1020.  
  1021.     lpErrno         - A pointer to the error code.
  1022.  
  1023. Return Value:
  1024.  
  1025.     The  return  value  is  ERROR_SUCCESS  if  the  operation  was  successful.
  1026.     Otherwise  the  value SOCKET_ERROR is returned, and a specific error number
  1027.     is available in lpErrno.
  1028.  
  1029. --*/
  1030. {
  1031.     INT ReturnValue;
  1032.  
  1033.     if (PREAPINOTIFY(( DTCODE_WSPEnumNetworkEvents,
  1034.                        &ReturnValue,
  1035.                        m_lib_name,
  1036.                        &s,
  1037.                        &hEventObject,
  1038.                        &lpNetworkEvents,
  1039.                        &lpErrno)) ) {
  1040.         return(ReturnValue);
  1041.     }
  1042.  
  1043.     ReturnValue = m_proctable->lpWSPEnumNetworkEvents(
  1044.         s,
  1045.         hEventObject,
  1046.         lpNetworkEvents,
  1047.         lpErrno);
  1048.  
  1049.     POSTAPINOTIFY(( DTCODE_WSPEnumNetworkEvents,
  1050.                     &ReturnValue,
  1051.                     m_lib_name,
  1052.                     &s,
  1053.                     &hEventObject,
  1054.                     &lpNetworkEvents,
  1055.                     &lpErrno));
  1056.  
  1057.     return(ReturnValue);
  1058.  
  1059. }
  1060.  
  1061.  
  1062.  
  1063. inline INT
  1064. DPROVIDER::WSPEventSelect(
  1065.     IN SOCKET s,
  1066.     IN OUT WSAEVENT hEventObject,
  1067.     IN long lNetworkEvents,
  1068.     OUT INT FAR *lpErrno
  1069.     )
  1070. /*++
  1071. Routine Description:
  1072.  
  1073.     Specify  an  event object to be associated with the supplied set of network
  1074.     events.
  1075.  
  1076. Arguments:
  1077.  
  1078.     s              - A descriptor identifying the socket.
  1079.  
  1080.     hEventObject   - A  handle  identifying  the  event object to be associated
  1081.                      with the supplied set of network events.
  1082.  
  1083.     lNetworkEvents - A  bitmask  which  specifies  the  combination  of network
  1084.                      events in which the WinSock client has interest.
  1085.  
  1086.     lpErrno        - A pointer to the error code.
  1087.  
  1088. Return Value:
  1089.  
  1090.     The return value is 0 if the WinSock client's specification of the network
  1091.     events and the associated event object was successful. Otherwise the value
  1092.     SOCKET_ERROR is returned, and a specific error number is available in
  1093.     lpErrno
  1094.  
  1095. --*/
  1096. {
  1097.     INT ReturnValue;
  1098.  
  1099.     if (PREAPINOTIFY(( DTCODE_WSPEventSelect,
  1100.                        &ReturnValue,
  1101.                        m_lib_name,
  1102.                        &s,
  1103.                        &hEventObject,
  1104.                        &lNetworkEvents,
  1105.                        &lpErrno)) ) {
  1106.         return(ReturnValue);
  1107.     }
  1108.  
  1109.     ReturnValue = m_proctable->lpWSPEventSelect(
  1110.         s,
  1111.         hEventObject,
  1112.         lNetworkEvents,
  1113.         lpErrno);
  1114.  
  1115.     POSTAPINOTIFY(( DTCODE_WSPEventSelect,
  1116.                     &ReturnValue,
  1117.                     m_lib_name,
  1118.                     &s,
  1119.                     &hEventObject,
  1120.                     &lNetworkEvents,
  1121.                     &lpErrno));
  1122.  
  1123.     return(ReturnValue);
  1124.  
  1125. }
  1126.  
  1127.  
  1128.  
  1129. inline INT
  1130. DPROVIDER::WSPGetOverlappedResult(
  1131.     IN SOCKET s,
  1132.     IN LPWSAOVERLAPPED lpOverlapped,
  1133.     IN LPDWORD lpcbTransfer,
  1134.     IN BOOL fWait,
  1135.     OUT LPDWORD lpdwFlags,
  1136.     OUT INT FAR *lpErrno
  1137.     )
  1138. /*++
  1139. Routine Description:
  1140.  
  1141.     Returns the results of an overlapped operation on the specified socket.
  1142.  
  1143. Arguments:
  1144.  
  1145.     s            - Identifies  the  socket.   This  is the same socket that was
  1146.                    specified  when  the  overlapped  operation was started by a
  1147.                    call to WSPRecv(), WSPRecvFrom(), WSPSend(), WSPSendTo(), or
  1148.                    WSPIoctl().
  1149.  
  1150.     lpOverlapped - Points to a WSAOVERLAPPED structure that was specified
  1151.                    when the overlapped operation was started.
  1152.  
  1153.     lpcbTransfer - Points to a 32-bit variable that receives the number of
  1154.                    bytes that were actually transferred by a send or receive
  1155.                    operation, or by WSPIoctl().
  1156.  
  1157.     fWait        - Specifies  whether  the function should wait for the pending
  1158.                    overlapped  operation  to  complete.   If TRUE, the function
  1159.                    does  not return until the operation has been completed.  If
  1160.                    FALSE  and  the  operation  is  still  pending, the function
  1161.                    returns FALSE and lperrno is WSA_IO_INCOMPLETE.
  1162.  
  1163.     lpdwFlags    - Points  to  a  32-bit variable that will receive one or more
  1164.                    flags   that  supplement  the  completion  status.   If  the
  1165.                    overlapped   operation   was   initiated  via  WSPRecv()  or
  1166.                    WSPRecvFrom(), this parameter will contain the results value
  1167.                    for lpFlags parameter.
  1168.  
  1169.     lpErrno      - A pointer to the error code.
  1170.  
  1171. Return Value:
  1172.  
  1173.     If WSPGetOverlappedResult() succeeds,the return value is TRUE.  This means
  1174.     that the overlapped operation has completed successfully and that the value
  1175.     pointed  to  by lpcbTransfer has been updated.  If WSPGetOverlappedResult()
  1176.     returns  FALSE,  this  means  that  either the overlapped operation has not
  1177.     completed  or  the  overlapped operation completed but with errors, or that
  1178.     completion  status  could  not  be  determined due to errors in one or more
  1179.     parameters  to  WSPGetOverlappedResult().  On failure, the value pointed to
  1180.     by  lpcbTransfer  will  not be updated.  lpErrno indicates the cause of the
  1181.     failure (either of WSPGetOverlappedResult() or of the associated overlapped
  1182.     operation).
  1183.  
  1184. --*/
  1185. {
  1186.     INT ReturnValue;
  1187.  
  1188.     if (PREAPINOTIFY(( DTCODE_WSPGetOverlappedResult,
  1189.                        &ReturnValue,
  1190.                        m_lib_name,
  1191.                        &s,
  1192.                        &lpOverlapped,
  1193.                        &lpcbTransfer,
  1194.                        &fWait,
  1195.                        &lpdwFlags,
  1196.                        &lpErrno)) ) {
  1197.         return(ReturnValue);
  1198.     }
  1199.  
  1200.     ReturnValue = m_proctable->lpWSPGetOverlappedResult(
  1201.         s,
  1202.         lpOverlapped,
  1203.         lpcbTransfer,
  1204.         fWait,
  1205.         lpdwFlags,
  1206.         lpErrno);
  1207.  
  1208.     POSTAPINOTIFY(( DTCODE_WSPGetOverlappedResult,
  1209.                     &ReturnValue,
  1210.                     m_lib_name,
  1211.                     &s,
  1212.                     &lpOverlapped,
  1213.                     &lpcbTransfer,
  1214.                     &fWait,
  1215.                     &lpdwFlags,
  1216.                     &lpErrno));
  1217.  
  1218.     return(ReturnValue);
  1219. }
  1220.  
  1221.  
  1222.  
  1223. inline INT
  1224. DPROVIDER::WSPGetPeerName(
  1225.     IN SOCKET s,
  1226.     OUT struct sockaddr FAR *name,
  1227.     OUT INT FAR *namelen,
  1228.     OUT INT FAR *lpErrno
  1229.     )
  1230. /*++
  1231. Routine Description:
  1232.  
  1233.     Get the address of the peer to which a socket is connected.
  1234.  
  1235. Arguments:
  1236.  
  1237.     s       - A descriptor identifying a connected socket.
  1238.  
  1239.     name    - A  pointer  to  the structure which is to receive the name of the
  1240.               peer.
  1241.  
  1242.     namelen - A  pointer  to  an integer which, on input, indicates the size of
  1243.               the  structure  pointed  to  by name, and on output indicates the
  1244.               size of the returned name.
  1245.  
  1246.     lpErrno - A pointer to the error code.
  1247.  
  1248. Return Value:
  1249.  
  1250.     If  no  error occurs, WSPGetPeerName() returns ERROR_SUCCESS.  Otherwise, a
  1251.     value  of  SOCKET_ERROR is returned, and a specific error code is available
  1252.     in lpErrno
  1253.  
  1254. --*/
  1255. {
  1256.     INT ReturnValue;
  1257.  
  1258.     if (PREAPINOTIFY(( DTCODE_WSPGetPeerName,
  1259.                        &ReturnValue,
  1260.                        m_lib_name,
  1261.                        &s,
  1262.                        &name,
  1263.                        &namelen,
  1264.                        &lpErrno)) ) {
  1265.         return(ReturnValue);
  1266.     }
  1267.  
  1268.     ReturnValue = m_proctable->lpWSPGetPeerName(
  1269.         s,
  1270.         name,
  1271.         namelen,
  1272.         lpErrno);
  1273.  
  1274.     POSTAPINOTIFY(( DTCODE_WSPGetPeerName,
  1275.                     &ReturnValue,
  1276.                     m_lib_name,
  1277.                     &s,
  1278.                     &name,
  1279.                     &namelen,
  1280.                     &lpErrno));
  1281.  
  1282.     return(ReturnValue);
  1283. }
  1284.  
  1285.  
  1286.  
  1287. inline INT
  1288. DPROVIDER::WSPGetQOSByName(
  1289.     IN SOCKET s,
  1290.     IN LPWSABUF lpQOSName,
  1291.     IN LPQOS lpQOS,
  1292.     OUT INT FAR *lpErrno
  1293.     )
  1294. /*++
  1295. Routine Description:
  1296.  
  1297.     Initializes a QOS structure based on a named template.
  1298.  
  1299. Arguments:
  1300.  
  1301.     s         - A descriptor identifying a socket.
  1302.  
  1303.     lpQOSName - Specifies the QOS template name.
  1304.  
  1305.     lpQOS     - A pointer to the QOS structure to be filled.
  1306.  
  1307.     lpErrno   - A pointer to the error code.
  1308.  
  1309. Return Value:
  1310.  
  1311.     If the function succeeds, the return value is TRUE.  If the function fails,
  1312.     the  return  value  is  FALSE, and  a  specific error code is available in
  1313.     lpErrno.
  1314.  
  1315. --*/
  1316. {
  1317.     INT ReturnValue;
  1318.  
  1319.     if (PREAPINOTIFY(( DTCODE_WSPGetQOSByName,
  1320.                        &ReturnValue,
  1321.                        m_lib_name,
  1322.                        &s,
  1323.                        &lpQOSName,
  1324.                        &lpQOS,
  1325.                        &lpErrno)) ) {
  1326.         return(ReturnValue);
  1327.     }
  1328.  
  1329.     ReturnValue = m_proctable->lpWSPGetQOSByName(
  1330.         s,
  1331.         lpQOSName,
  1332.         lpQOS,
  1333.         lpErrno);
  1334.  
  1335.     POSTAPINOTIFY(( DTCODE_WSPGetQOSByName,
  1336.                     &ReturnValue,
  1337.                     m_lib_name,
  1338.                     &s,
  1339.                     &lpQOSName,
  1340.                     &lpQOS,
  1341.                     &lpErrno));
  1342.  
  1343.     return(ReturnValue);
  1344. }
  1345.  
  1346.  
  1347.  
  1348. inline INT
  1349. DPROVIDER::WSPGetSockName(
  1350.     IN SOCKET s,
  1351.     OUT struct sockaddr FAR *name,
  1352.     OUT INT FAR *namelen,
  1353.     OUT INT FAR *lpErrno
  1354.     )
  1355. /*++
  1356. Routine Description:
  1357.  
  1358.     Get the local name for a socket.
  1359.  
  1360. Arguments:
  1361.  
  1362.     s       - A descriptor identifying a bound socket.
  1363.  
  1364.     name    - A pointer to a structure used to supply the address (name) of the
  1365.               socket.
  1366.  
  1367.     namelen - A  pointer  to  an integer which, on input, indicates the size of
  1368.               the  structure  pointed  to  by name, and on output indicates the
  1369.               size of the returned name
  1370.  
  1371.     lpErrno - A Pointer to the error code.
  1372.  
  1373. Return Value:
  1374.  
  1375.     If  no  error occurs, WSPGetSockName() returns ERROR_SUCCESS.  Otherwise, a
  1376.     value  of  SOCKET_ERROR is returned, and a specific error code is available
  1377.     in lpErrno.
  1378.  
  1379. --*/
  1380. {
  1381.     INT ReturnValue;
  1382.  
  1383.     if (PREAPINOTIFY(( DTCODE_WSPGetSockName,
  1384.                        &ReturnValue,
  1385.                        m_lib_name,
  1386.                        &s,
  1387.                        &name,
  1388.                        &namelen,
  1389.                        &lpErrno)) ) {
  1390.         return(ReturnValue);
  1391.     }
  1392.  
  1393.     ReturnValue = m_proctable->lpWSPGetSockName(
  1394.         s,
  1395.         name,
  1396.         namelen,
  1397.         lpErrno);
  1398.  
  1399.     POSTAPINOTIFY(( DTCODE_WSPGetSockName,
  1400.                     &ReturnValue,
  1401.                     m_lib_name,
  1402.                     &s,
  1403.                     &name,
  1404.                     &namelen,
  1405.                     &lpErrno));
  1406.  
  1407.     return(ReturnValue);
  1408. }
  1409.  
  1410.  
  1411.  
  1412. inline INT
  1413. DPROVIDER::WSPGetSockOpt(
  1414.     IN SOCKET s,
  1415.     IN INT level,
  1416.     IN INT optname,
  1417.     OUT char FAR *optval,
  1418.     OUT INT FAR *optlen,
  1419.     OUT INT FAR *lpErrno
  1420.     )
  1421. /*++
  1422. Routine Description:
  1423.  
  1424.     Retrieve a socket option.
  1425.  
  1426. Arguments:
  1427.  
  1428.     s       - A descriptor identifying a socket.
  1429.  
  1430.     level   - The  level  at  which the option is defined; the supported levels
  1431.               include SOL_SOCKET (See annex for more protocol-specific levels.)
  1432.  
  1433.     optname - The socket option for which the value is to be retrieved.
  1434.  
  1435.     optval  - A  pointer  to  the  buffer  in which the value for the requested
  1436.               option is to be returned.
  1437.  
  1438.     optlen  - A pointer to the size of the optval buffer.
  1439.  
  1440.     lpErrno - A pointer to the error code.
  1441.  
  1442. Return Value:
  1443.  
  1444.     If  no  error  occurs,  WSPGetSockOpt()  returns  0.  Otherwise, a value of
  1445.     SOCKET_ERROR  is  returned,  and  a  specific  error  code  is available in
  1446.     lpErrno.
  1447.  
  1448. --*/
  1449. {
  1450.     INT ReturnValue;
  1451.  
  1452.     if (PREAPINOTIFY(( DTCODE_WSPGetSockOpt,
  1453.                        &ReturnValue,
  1454.                        m_lib_name,
  1455.                        &s,
  1456.                        &level,
  1457.                        &optname,
  1458.                        &optval,
  1459.                        &optlen,
  1460.                        &lpErrno)) ) {
  1461.         return(ReturnValue);
  1462.     }
  1463.  
  1464.     ReturnValue = m_proctable->lpWSPGetSockOpt(
  1465.         s,
  1466.         level,
  1467.         optname,
  1468.         optval,
  1469.         optlen,
  1470.         lpErrno);
  1471.  
  1472.     POSTAPINOTIFY(( DTCODE_WSPGetSockOpt,
  1473.                     &ReturnValue,
  1474.                     m_lib_name,
  1475.                     &s,
  1476.                     &level,
  1477.                     &optname,
  1478.                     &optval,
  1479.                     &optlen,
  1480.                     &lpErrno));
  1481.  
  1482.     return(ReturnValue);
  1483. }
  1484.  
  1485.  
  1486. inline INT
  1487. DPROVIDER::WSPIoctl(
  1488.     IN SOCKET s,
  1489.     IN DWORD dwIoControlCode,
  1490.     IN LPVOID lpvInBuffer,
  1491.     IN DWORD cbInBuffer,
  1492.     IN LPVOID lpvOutBuffer,
  1493.     IN DWORD cbOutBuffer,
  1494.     IN LPDWORD lpcbBytesReturned,
  1495.     IN LPWSAOVERLAPPED lpOverlapped,
  1496.     IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine,
  1497.     IN LPWSATHREADID lpThreadId,
  1498.     OUT INT FAR *lpErrno
  1499.     )
  1500. /*++
  1501. Routine Description:
  1502.  
  1503.     Control the mode of a socket.
  1504.  
  1505. Arguments:
  1506.  
  1507.     s                   - Handle to a socket
  1508.  
  1509.     dwIoControlCode     - Control code of operation to perform
  1510.  
  1511.     lpvInBuffer         - Address of input buffer
  1512.  
  1513.     cbInBuffer          - Size of input buffer
  1514.  
  1515.     lpvOutBuffer        - Address of output buffer
  1516.  
  1517.     cbOutBuffer         - Size of output buffer
  1518.  
  1519.     lpcbBytesReturned   - A pointer to the size of output buffer's contents.
  1520.  
  1521.     lpOverlapped        - Address of WSAOVERLAPPED structure
  1522.  
  1523.     lpCompletionRoutine - A  pointer  to the completion routine called when the
  1524.                           operation has been completed.
  1525.  
  1526.     lpThreadId          - A  pointer to a thread ID structure to be used by the
  1527.                           provider
  1528.  
  1529.     lpErrno             - A pointer to the error code.
  1530.  
  1531. Return Value:
  1532.  
  1533.     If  no error occurs and the operation has completed immediately, WSPIoctl()
  1534.     returns  0.   Note  that in this case the completion routine, if specified,
  1535.     will  have  already  been  queued.   Otherwise, a value of SOCKET_ERROR is
  1536.     returned, and  a  specific  error code is available in lpErrno.  The error
  1537.     code  WSA_IO_PENDING  indicates  that  an  overlapped  operation  has  been
  1538.     successfully  initiated  and  that  conpletion will be indicated at a later
  1539.     time.   Any  other  error  code  indicates that no overlapped operation was
  1540.     initiated and no completion indication will occur.
  1541.  
  1542. --*/
  1543. {
  1544.     INT ReturnValue;
  1545.  
  1546.     if (PREAPINOTIFY(( DTCODE_WSPIoctl,
  1547.                        &ReturnValue,
  1548.                        m_lib_name,
  1549.                        &s,
  1550.                        &dwIoControlCode,
  1551.                        &lpvInBuffer,
  1552.                        &cbInBuffer,
  1553.                        &lpvOutBuffer,
  1554.                        &cbOutBuffer,
  1555.                        &lpcbBytesReturned,
  1556.                        &lpOverlapped,
  1557.                        &lpCompletionRoutine,
  1558.                        &lpThreadId,
  1559.                        &lpErrno)) ) {
  1560.         return(ReturnValue);
  1561.     }
  1562.  
  1563.     ReturnValue = m_proctable->lpWSPIoctl(
  1564.         s,
  1565.         dwIoControlCode,
  1566.         lpvInBuffer,
  1567.         cbInBuffer,
  1568.         lpvOutBuffer,
  1569.         cbOutBuffer,
  1570.         lpcbBytesReturned,
  1571.         lpOverlapped,
  1572.         lpCompletionRoutine,
  1573.         lpThreadId,
  1574.         lpErrno);
  1575.  
  1576.     POSTAPINOTIFY(( DTCODE_WSPIoctl,
  1577.                     &ReturnValue,
  1578.                     m_lib_name,
  1579.                     &s,
  1580.                     &dwIoControlCode,
  1581.                     &lpvInBuffer,
  1582.                     &cbInBuffer,
  1583.                     &lpvOutBuffer,
  1584.                     &cbOutBuffer,
  1585.                     &lpcbBytesReturned,
  1586.                     &lpOverlapped,
  1587.                     &lpCompletionRoutine,
  1588.                     &lpThreadId,
  1589.                     &lpErrno));
  1590.  
  1591.     return(ReturnValue);
  1592. }
  1593.  
  1594.  
  1595.  
  1596. inline INT
  1597. DPROVIDER::WSPJoinLeaf(
  1598.     IN SOCKET s,
  1599.     IN const struct sockaddr FAR *name,
  1600.     IN INT namelen,
  1601.     IN LPWSABUF lpCallerData,
  1602.     IN LPWSABUF lpCalleeData,
  1603.     IN LPQOS lpSQOS,
  1604.     IN LPQOS lpGQOS,
  1605.     IN DWORD dwFlags,
  1606.     OUT INT FAR *lpErrno
  1607.     )
  1608. /*++
  1609. Routine Description:
  1610.  
  1611.     Join  a  leaf  node  into  a multipoint session, exchange connect data, and
  1612.     specify needed quality of service based on the supplied flow specs.
  1613.  
  1614. Arguments:
  1615.  
  1616.     s            - A descriptor identifying a multipoint socket.
  1617.  
  1618.     name         - The name of the peer to which the socket is to be joined.
  1619.  
  1620.     namelen      - The length of the name.
  1621.  
  1622.     lpCallerData - A  pointer to the user data that is to be transferred to the
  1623.                    peer during multipoint session establishment.
  1624.  
  1625.     lpCalleeData - A  pointer  to  the user data that is to be transferred back
  1626.                    from the peer during multipoint session establishment.
  1627.  
  1628.     lpSQOS       - A  pointer  to  the  flow  specs  for socket s, one for each
  1629.                    direction.
  1630.  
  1631.     lpGQOS       - A  pointer  to  the  flow  specs  for  the  socket group (if
  1632.                    applicable).
  1633.  
  1634.     dwFlags      - Flags  to  indicate  that  the socket is acting as a sender,
  1635.                    receiver, or both.
  1636.  
  1637.     lpErrno      - A pointer to the error code.
  1638.  
  1639. Return Value:
  1640.  
  1641.     If no error occurs,
  1642. WSPJoinLeaf() returns a value of type SOCKET which is a
  1643.     descriptor  for the newly created multipoint socket.  Otherwise,a value of
  1644.     INVALID_SOCKET  is  returned, and  a  specific  error code is available in
  1645.     lpErrno.
  1646.  
  1647. --*/
  1648. {
  1649.     INT ReturnValue;
  1650.  
  1651.     if (PREAPINOTIFY(( DTCODE_WSPJoinLeaf,
  1652.                        &ReturnValue,
  1653.                        m_lib_name,
  1654.                        &s,
  1655.                        &name,
  1656.                        &namelen,
  1657.                        &lpCallerData,
  1658.                        &lpCalleeData,
  1659.                        &lpSQOS,
  1660.                        &lpGQOS,
  1661.                        &dwFlags,
  1662.                        &lpErrno)) ) {
  1663.         return(ReturnValue);
  1664.     }
  1665.  
  1666.     ReturnValue = m_proctable->lpWSPJoinLeaf(
  1667.         s,
  1668.         name,
  1669.         namelen,
  1670.         lpCallerData,
  1671.         lpCalleeData,
  1672.         lpSQOS,
  1673.         lpGQOS,
  1674.         dwFlags,
  1675.         lpErrno);
  1676.  
  1677.     POSTAPINOTIFY(( DTCODE_WSPJoinLeaf,
  1678.                     &ReturnValue,
  1679.                     m_lib_name,
  1680.                     &s,
  1681.                     &name,
  1682.                     &namelen,
  1683.                     &lpCallerData,
  1684.                     &lpCalleeData,
  1685.                     &lpSQOS,
  1686.                     &lpGQOS,
  1687.                     &dwFlags,
  1688.                     &lpErrno));
  1689.  
  1690.     return(ReturnValue);
  1691.  
  1692. }
  1693.  
  1694.  
  1695.  
  1696. inline INT
  1697. DPROVIDER::WSPListen(
  1698.     IN SOCKET s,
  1699.     IN INT backlog,
  1700.     OUT INT FAR *lpErrno
  1701.     )
  1702. /*++
  1703. Routine Description:
  1704.  
  1705.     Establish a socket to listen for incoming connections.
  1706.  
  1707. Arguments:
  1708.  
  1709.     s       - A descriptor identifying a bound,
  1710. unconnected socket.
  1711.  
  1712.     backlog - The  maximum length to which the queue of pending connections may
  1713.               grow.   If  this  value  is  SOMAXCONN,
  1714. then the service provider
  1715.               should set the backlog to a maximum "reasonable" value.
  1716.  
  1717.     lpErrno - A pointer to the error code.
  1718.  
  1719. Return Value:
  1720.  
  1721.     If  no  error  occurs, WSPListen()  returns  0.   Otherwise, a  value  of
  1722.     SOCKET_ERROR  is  returned, and  a  specific  error  code  is available in
  1723.     lpErrno.
  1724.  
  1725. --*/
  1726. {
  1727.     INT ReturnValue;
  1728.  
  1729.     if (PREAPINOTIFY(( DTCODE_WSPListen,
  1730.                        &ReturnValue,
  1731.                        m_lib_name,
  1732.                        &s,
  1733.                        &backlog,
  1734.                        &lpErrno)) ) {
  1735.         return(ReturnValue);
  1736.     }
  1737.  
  1738.     ReturnValue = m_proctable->lpWSPListen(
  1739.         s,
  1740.         backlog,
  1741.         lpErrno);
  1742.  
  1743.     POSTAPINOTIFY(( DTCODE_WSPListen,
  1744.                     &ReturnValue,
  1745.                     m_lib_name,
  1746.                     &s,
  1747.                     &backlog,
  1748.                     &lpErrno));
  1749.  
  1750.     return(ReturnValue);
  1751.  
  1752. }
  1753.  
  1754.  
  1755.  
  1756. inline INT
  1757. DPROVIDER::WSPRecv(
  1758.     IN SOCKET s,
  1759.     IN LPWSABUF lpBuffers,
  1760.     IN DWORD dwBufferCount,
  1761.     IN LPDWORD lpNumberOfBytesRecvd,
  1762.     IN OUT LPDWORD lpFlags,
  1763.     IN LPWSAOVERLAPPED lpOverlapped,
  1764.     IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine,
  1765.     IN LPWSATHREADID lpThreadId,
  1766.     OUT INT FAR *lpErrno
  1767.     )
  1768. /*++
  1769. Routine Description:
  1770.  
  1771.     Receive data on a socket.
  1772.  
  1773. Arguments:
  1774.  
  1775.     s                    - A descriptor identifying a connected socket.
  1776.  
  1777.     lpBuffers            - A  pointer  to  an array of WSABUF structures.  Each
  1778.                            WSABUF  structure contains a pointer to a buffer and
  1779.                            the length of the buffer.
  1780.  
  1781.     dwBufferCount        - The  number  of  WSABUF  structures in the lpBuffers
  1782.                            array.
  1783.  
  1784.     lpNumberOfBytesRecvd - A  pointer  to  the number of bytes received by this
  1785.                            call.
  1786.  
  1787.     lpFlags              - A pointer to flags.
  1788.  
  1789.     lpOverlapped         - A pointer to a WSAOVERLAPPED structure.
  1790.  
  1791.     lpCompletionRoutine  - A  pointer to the completion routine called when the
  1792.                            receive operation has been completed.
  1793.  
  1794.     lpThreadId           - A pointer to a thread ID structure to be used by the
  1795.                            provider in a subsequent call to WPUQueueApc().
  1796.  
  1797.     lpErrno              - A pointer to the error code.
  1798.  
  1799. Return Value:
  1800.  
  1801.     If  no  error  occurs  and the receive operation has completed immediately,
  1802.     WSPRecv() returns the number of bytes received.  If the connection has been
  1803.     closed, it  returns  0.  Note that in this case the completion routine, if
  1804.     specified,  will   have  already  been  queued.   Otherwise, a  value  of
  1805.     SOCKET_ERROR  is  returned, and  a  specific  error  code  is available in
  1806.     lpErrno.   The  error  code WSA_IO_PENDING indicates that the overlapped an
  1807.     operation  has  been  successfully  initiated  and  that completion will be
  1808.     indicated  at  a  later  time.   Any  other  error  code  indicates that no
  1809.     overlapped  operations  was  initiated  and  no  completion indication will
  1810.     occur.
  1811. --*/
  1812. {
  1813.     INT ReturnValue;
  1814.  
  1815.     if (PREAPINOTIFY(( DTCODE_WSPRecv,
  1816.                        &ReturnValue,
  1817.                        m_lib_name,
  1818.                        &s,
  1819.                        &lpBuffers,
  1820.                        &dwBufferCount,
  1821.                        &lpNumberOfBytesRecvd,
  1822.                        &lpFlags,
  1823.                        &lpOverlapped,
  1824.                        &lpCompletionRoutine,
  1825.                        &lpThreadId,
  1826.                        &lpErrno)) ) {
  1827.         return(ReturnValue);
  1828.     }
  1829.  
  1830.     ReturnValue = m_proctable->lpWSPRecv(
  1831.         s,
  1832.         lpBuffers,
  1833.         dwBufferCount,
  1834.         lpNumberOfBytesRecvd,
  1835.         lpFlags,
  1836.         lpOverlapped,
  1837.         lpCompletionRoutine,
  1838.         lpThreadId,
  1839.         lpErrno);
  1840.  
  1841.     POSTAPINOTIFY(( DTCODE_WSPRecv,
  1842.                     &ReturnValue,
  1843.                     m_lib_name,
  1844.                     &s,
  1845.                     &lpBuffers,
  1846.                     &dwBufferCount,
  1847.                     &lpNumberOfBytesRecvd,
  1848.                     &lpFlags,
  1849.                     &lpOverlapped,
  1850.                     &lpCompletionRoutine,
  1851.                     &lpThreadId,
  1852.                     &lpErrno));
  1853.  
  1854.     return(ReturnValue);
  1855. }
  1856.  
  1857.  
  1858.  
  1859. inline INT
  1860. DPROVIDER::WSPRecvDisconnect(
  1861.     IN SOCKET s,
  1862.     IN LPWSABUF lpInboundDisconnectData,
  1863.     OUT INT FAR *lpErrno
  1864.     )
  1865. /*++
  1866. Routine Description:
  1867.  
  1868.     Terminate  reception  on  a socket, and retrieve the disconnect data if the
  1869.     socket is connection-oriented.
  1870.  
  1871. Arguments:
  1872.  
  1873.     s                       - A descriptor identifying a socket.
  1874.  
  1875.     lpInboundDisconnectData - A  pointer to a buffer into which disconnect data
  1876.                               is to be copied.
  1877.  
  1878.     lpErrno                 - A pointer to the error code.
  1879.  
  1880. Return Value:
  1881.  
  1882.     If  no error occurs, WSPRecvDisconnect() returns ERROR_SUCCESS.  Otherwise,
  1883.     a value of SOCKET_ERROR is returned, and a specific error code is available
  1884.     in lpErrno.
  1885.  
  1886. --*/
  1887. {
  1888.     INT ReturnValue;
  1889.  
  1890.     if (PREAPINOTIFY(( DTCODE_WSPRecvDisconnect,
  1891.                        &ReturnValue,
  1892.                        m_lib_name,
  1893.                        &s,
  1894.                        &lpInboundDisconnectData,
  1895.                        &lpErrno)) ) {
  1896.         return(ReturnValue);
  1897.     }
  1898.  
  1899.     ReturnValue = m_proctable->lpWSPRecvDisconnect(
  1900.         s,
  1901.         lpInboundDisconnectData,
  1902.         lpErrno);
  1903.  
  1904.     POSTAPINOTIFY(( DTCODE_WSPRecvDisconnect,
  1905.                     &ReturnValue,
  1906.                     m_lib_name,
  1907.                     &s,
  1908.                     &lpInboundDisconnectData,
  1909.                     &lpErrno));
  1910.  
  1911.     return(ReturnValue);
  1912.  
  1913. }
  1914.  
  1915.  
  1916.  
  1917. inline INT
  1918. DPROVIDER::WSPRecvFrom(
  1919.     IN  SOCKET s,
  1920.     IN  LPWSABUF lpBuffers,
  1921.     IN  DWORD dwBufferCount,
  1922.     IN  LPDWORD lpNumberOfBytesRecvd,
  1923.     IN  OUT LPDWORD lpFlags,
  1924.     OUT struct sockaddr FAR *  lpFrom,
  1925.     IN  LPINT lpFromlen,
  1926.     IN  LPWSAOVERLAPPED lpOverlapped,
  1927.     IN  LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine,
  1928.     IN LPWSATHREADID lpThreadId,
  1929.     OUT INT FAR *lpErrno
  1930.     )
  1931. /*++
  1932. Routine Description:
  1933.  
  1934.     Receive a datagram and store the source address.
  1935.  
  1936. Arguments:
  1937.  
  1938.     s                    - A descriptor identifying a socket.
  1939.  
  1940.     lpBuffers            - A  pointer  to  an array of WSABUF structures.  Each
  1941.                            WSABUF  structure contains a pointer to a buffer and
  1942.                            the length of the buffer.
  1943.  
  1944.     dwBufferCount        - The  number  of  WSABUF  structures in the lpBuffers
  1945.                            array.
  1946.  
  1947.     lpNumberOfBytesRecvd - A  pointer  to  the number of bytes received by this
  1948.                            call.
  1949.  
  1950.     lpFlags              - A pointer to flags.
  1951.  
  1952.     lpFrom               - An  optional pointer to a buffer which will hold the
  1953.                            source address upon the completion of the overlapped
  1954.                            operation.
  1955.  
  1956.     lpFromlen            - A  pointer  to the size of the from buffer, required
  1957.                            only if lpFrom is specified.
  1958.  
  1959.     lpOverlapped         - A pointer to a WSAOVERLAPPED structure.
  1960.  
  1961.     CompletionRoutine    - A  pointer to the completion routine called when the
  1962.                            receive operation has been completed.
  1963.  
  1964.     lpThreadId           - A pointer to a thread ID structure to be used by the
  1965.                            provider in a subsequent call to WPUQueueApc().
  1966.  
  1967.     lpErrno              - A pointer to the error code.
  1968.  
  1969. Return Value:
  1970.  
  1971.     If  no  error  occurs  and the receive operation has completed immediately,
  1972.     WSPRecvFrom()  returns the number of bytes received.  If the connection has
  1973.     been  closed, it returns 0.  Note that in this case the completion routine,
  1974.     if  specified  will  have  already  been  queued.   Otherwise,  a  value of
  1975.     SOCKET_ERROR  is  returned, and  a  specific  error  code  is available in
  1976.     lpErrno.   The  error  code  WSA_IO_PENDING  indicates  that the overlapped
  1977.     operation  has  been  successfully  initiated  and  that completion will be
  1978.     indicated  at  a  later  time.   Any  other  error  code  indicates that no
  1979.     overlapped  operations  was  initiated  and  no  completion indication will
  1980.     occur.
  1981.  
  1982. --*/
  1983. {
  1984.     INT ReturnValue;
  1985.  
  1986.     if (PREAPINOTIFY(( DTCODE_WSPRecvFrom,
  1987.                        &ReturnValue,
  1988.                        m_lib_name,
  1989.                        &s,
  1990.                        &lpBuffers,
  1991.                        &dwBufferCount,
  1992.                        &lpNumberOfBytesRecvd,
  1993.                        &lpFlags,
  1994.                        &lpFrom,
  1995.                        &lpFromlen,
  1996.                        &lpOverlapped,
  1997.                        &lpCompletionRoutine,
  1998.                        &lpThreadId,
  1999.                        &lpErrno)) ) {
  2000.         return(ReturnValue);
  2001.     }
  2002.  
  2003.     ReturnValue = m_proctable->lpWSPRecvFrom(
  2004.         s,
  2005.         lpBuffers,
  2006.         dwBufferCount,
  2007.         lpNumberOfBytesRecvd,
  2008.         lpFlags,
  2009.         lpFrom,
  2010.         lpFromlen,
  2011.         lpOverlapped,
  2012.         lpCompletionRoutine,
  2013.         lpThreadId,
  2014.         lpErrno);
  2015.  
  2016.     POSTAPINOTIFY(( DTCODE_WSPRecvFrom,
  2017.                     &ReturnValue,
  2018.                     m_lib_name,
  2019.                     &s,
  2020.                     &lpBuffers,
  2021.                     &dwBufferCount,
  2022.                     &lpNumberOfBytesRecvd,
  2023.                     &lpFlags,
  2024.                     &lpFrom,
  2025.                     &lpFromlen,
  2026.                     &lpOverlapped,
  2027.                     &lpCompletionRoutine,
  2028.                     &lpThreadId,
  2029.                     &lpErrno));
  2030.  
  2031.     return(ReturnValue);
  2032. }
  2033.  
  2034.  
  2035.  
  2036. inline INT
  2037. DPROVIDER::WSPSelect(
  2038.     IN INT nfds,
  2039.     IN OUT fd_set FAR *readfds,
  2040.     IN OUT fd_set FAR *writefds,
  2041.     IN OUT fd_set FAR *exceptfds,
  2042.     IN const struct timeval FAR *timeout,
  2043.     OUT INT FAR *lpErrno
  2044.     )
  2045. /*++
  2046. Routine Description:
  2047.  
  2048.     Determine the status of one or more sockets.
  2049.  
  2050. Arguments:
  2051.  
  2052.     nfds      - This  argument  is  ignored  and  included only for the sake of
  2053.                 compatibility.
  2054.  
  2055.     readfds   - An  optional  pointer  to  a  set  of sockets to be checked for
  2056.                 readability.
  2057.  
  2058.     writefds  - An  optional  pointer  to  a  set  of sockets to be checked for
  2059.                 writability
  2060.  
  2061.     exceptfds - An  optional  pointer  to  a  set  of sockets to be checked for
  2062.                 errors.
  2063.  
  2064.     timeout   - The  maximum  time  for  WSPSelect()  to  wait, or  NULL for a
  2065.                 blocking operation.
  2066.  
  2067.     lpErrno   - A pointer to the error code.
  2068.  
  2069. Return Value:
  2070.  
  2071.     WSPSelect()  returns  the  total  number of descriptors which are ready and
  2072.     contained  in  the  fd_set  structures, 0  if  the  time limit expired, or
  2073.     SOCKET_ERROR  if an error occurred.  If the return value is SOCKET_ERROR, a
  2074.     specific error code is available in lpErrno.
  2075.  
  2076. --*/
  2077. {
  2078.     INT ReturnValue;
  2079.  
  2080.     if (PREAPINOTIFY(( DTCODE_WSPSelect,
  2081.                        &ReturnValue,
  2082.                        m_lib_name,
  2083.                        &nfds,
  2084.                        &readfds,
  2085.                        &writefds,
  2086.                        &exceptfds,
  2087.                        &timeout,
  2088.                        &lpErrno)) ) {
  2089.         return(ReturnValue);
  2090.     }
  2091.  
  2092.     ReturnValue = m_proctable->lpWSPSelect(
  2093.         nfds,
  2094.         readfds,
  2095.         writefds,
  2096.         exceptfds,
  2097.         timeout,
  2098.         lpErrno);
  2099.  
  2100.     POSTAPINOTIFY(( DTCODE_WSPSelect,
  2101.                     &ReturnValue,
  2102.                     m_lib_name,
  2103.                     &nfds,
  2104.                     &readfds,
  2105.                     &writefds,
  2106.                     &exceptfds,
  2107.                     &timeout,
  2108.                     &lpErrno));
  2109.  
  2110.     return(ReturnValue);
  2111. }
  2112.  
  2113.  
  2114.  
  2115.  
  2116. inline INT
  2117. DPROVIDER::WSPSend(
  2118.     IN SOCKET s,
  2119.     IN LPWSABUF lpBuffers,
  2120.     IN DWORD dwBufferCount,
  2121.     IN LPDWORD lpNumberOfBytesSent,
  2122.     IN DWORD dwFlags,
  2123.     IN LPWSAOVERLAPPED lpOverlapped,
  2124.     IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine,
  2125.     IN LPWSATHREADID lpThreadId,
  2126.     OUT INT FAR *lpErrno
  2127.     )
  2128. /*++
  2129. Routine Description:
  2130.  
  2131.     Send data on a connected socket.
  2132.  
  2133. Arguments:
  2134.  
  2135.     s                   - A descriptor identifying a connected socket.
  2136.  
  2137.     lpBuffers           - A  pointer  to  an  array of WSABUF structures.  Each
  2138.                           WSABUF  structure  contains a pointer to a buffer and
  2139.                           the length of the buffer.
  2140.  
  2141.     dwBufferCount       - The  number  of  WSABUF  structures  in the lpBuffers
  2142.                           array.
  2143.  
  2144.     lpNumberOfBytesSent - A pointer to the number of bytes sent by this call.
  2145.  
  2146.     dwFlags             - Flags.
  2147.  
  2148.     lpOverlapped        - A pointer to a WSAOVERLAPPED structure.
  2149.  
  2150.     lpCompletionRoutine - A  pointer  to the completion routine called when the
  2151.                           send operation has been completed.
  2152.  
  2153.     lpThreadId          - A  pointer to a thread ID structure to be used by the
  2154.                           provider in a subsequent call to WPUQueueApc().
  2155.  
  2156.     lpErrno             - A pointer to the error code.
  2157.  
  2158. Return Value:
  2159.  
  2160.     If  no  error  occurs  and  the  send  operation has completed immediately,
  2161.     WSPSend() returns the number of bytes received.  If the connection has been
  2162.     closed,  it  returns  0.  Note that in this case the completion routine, if
  2163.     specified, will   have  already  been  queued.   Otherwise, a  value  of
  2164.     SOCKET_ERROR  is  returned, and  a  specific  error  code  is available in
  2165.     lpErrno.   The  error  code  WSA_IO_PENDING  indicates  that the overlapped
  2166.     operation  has  been  successfully  initiated  and  that completion will be
  2167.     indicated  at  a  later  time.   Any  other  error  code  indicates that no
  2168.     overlapped operation was initiated and no completion indication will occur.
  2169.  
  2170. --*/
  2171. {
  2172.     INT ReturnValue;
  2173.  
  2174.     if (PREAPINOTIFY(( DTCODE_WSPSend,
  2175.                        &ReturnValue,
  2176.                        m_lib_name,
  2177.                        &s,
  2178.                        &lpBuffers,
  2179.                        &dwBufferCount,
  2180.                        &lpNumberOfBytesSent,
  2181.                        &dwFlags,
  2182.                        &lpOverlapped,
  2183.                        &lpCompletionRoutine,
  2184.                        &lpThreadId,
  2185.                        &lpErrno)) ) {
  2186.         return(ReturnValue);
  2187.     }
  2188.  
  2189.     ReturnValue = m_proctable->lpWSPSend(
  2190.         s,
  2191.         lpBuffers,
  2192.         dwBufferCount,
  2193.         lpNumberOfBytesSent,
  2194.         dwFlags,
  2195.         lpOverlapped,
  2196.         lpCompletionRoutine,
  2197.         lpThreadId,
  2198.         lpErrno);
  2199.  
  2200.     POSTAPINOTIFY(( DTCODE_WSPSend,
  2201.                     &ReturnValue,
  2202.                     m_lib_name,
  2203.                     &s,
  2204.                     &lpBuffers,
  2205.                     &dwBufferCount,
  2206.                     &lpNumberOfBytesSent,
  2207.                     &dwFlags,
  2208.                     &lpOverlapped,
  2209.                     &lpCompletionRoutine,
  2210.                     &lpThreadId,
  2211.                     &lpErrno));
  2212.  
  2213.     return(ReturnValue);
  2214. }
  2215.  
  2216.  
  2217.  
  2218. inline INT
  2219. DPROVIDER::WSPSendDisconnect(
  2220.     IN SOCKET s,
  2221.     IN LPWSABUF lpOutboundDisconnectData,
  2222.     OUT INT FAR *lpErrno
  2223.     )
  2224. /*++
  2225. Routine Description:
  2226.  
  2227.     Initiate  termination  of the connection for the socket and send disconnect
  2228.     data.
  2229.  
  2230. Arguments:
  2231.  
  2232.     s                        - A descriptor identifying a socket.
  2233.  
  2234.     lpOutboundDisconnectData - A pointer to the outgoing disconnect data.
  2235.  
  2236.     lpErrno                  - A pointer to the error code.
  2237.  
  2238. Return Value:
  2239.  
  2240.     If  no  error occurs, WSPSendDisconnect() returns 0.  Otherwise, a value of
  2241.     SOCKET_ERROR  is  returned, and  a  specific  error  code  is available in
  2242.     lpErrno.
  2243.  
  2244. --*/
  2245. {
  2246.     INT ReturnValue;
  2247.  
  2248.     if (PREAPINOTIFY(( DTCODE_WSPSendDisconnect,
  2249.                        &ReturnValue,
  2250.                        m_lib_name,
  2251.                        &s,
  2252.                        &lpOutboundDisconnectData,
  2253.                        &lpErrno)) ) {
  2254.         return(ReturnValue);
  2255.     }
  2256.  
  2257.     ReturnValue = m_proctable->lpWSPSendDisconnect(
  2258.         s,
  2259.         lpOutboundDisconnectData,
  2260.         lpErrno);
  2261.  
  2262.     POSTAPINOTIFY(( DTCODE_WSPSendDisconnect,
  2263.                     &ReturnValue,
  2264.                     m_lib_name,
  2265.                     &s,
  2266.                     &lpOutboundDisconnectData,
  2267.                     &lpErrno));
  2268.  
  2269.     return(ReturnValue);
  2270.  
  2271. }
  2272.  
  2273.  
  2274.  
  2275. inline INT
  2276. DPROVIDER::WSPSendTo(
  2277.     IN SOCKET s,
  2278.     IN LPWSABUF lpBuffers,
  2279.     IN DWORD dbBufferCount,
  2280.     IN LPDWORD lpNumberOfBytesSent,
  2281.     IN DWORD dwFlags,
  2282.     IN const struct sockaddr FAR *  lpTo,
  2283.     IN INT iTolen,
  2284.     IN LPWSAOVERLAPPED lpOverlapped,
  2285.     IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine,
  2286.     IN LPWSATHREADID lpThreadId,
  2287.     OUT INT FAR *lpErrno
  2288.     )
  2289. /*++
  2290. Routine Description:
  2291.  
  2292.     Send data to a specific destination using overlapped I/O.
  2293.  
  2294. Arguments:
  2295.  
  2296.     s                   - A descriptor identifying a socket.
  2297.  
  2298.     lpBuffers           - A  pointer  to  an  array of WSABUF structures.  Each
  2299.                           WSABUF  structure  contains a pointer to a buffer and
  2300.                           the length of the buffer.
  2301.  
  2302.     dwBufferCount       - The  number  of  WSABUF  structures  in the lpBuffers
  2303.                           array.
  2304.  
  2305.     lpNumberOfBytesSent - A pointer to the number of bytes sent by this call.
  2306.  
  2307.     dwFlags             - Flags.
  2308.  
  2309.     lpTo                - An  optional  pointer  to  the  address of the target
  2310.                           socket.
  2311.  
  2312.     iTolen              - The size of the address in lpTo.
  2313.  
  2314.     lpOverlapped        - A pointer to a WSAOVERLAPPED structure.
  2315.  
  2316.     lpCompletionRoutine - A  pointer  to the completion routine called when the
  2317.                           send operation has been completed.
  2318.  
  2319.     lpThreadId          - A  pointer to a thread ID structure to be used by the
  2320.                           provider in a subsequent call to WPUQueueApc().
  2321.  
  2322.     lpErrno             - A pointer to the error code.
  2323.  
  2324. Return Value:
  2325.  
  2326.     If  no  error  occurs  and the receive operation has completed immediately,
  2327.     WSPSendTo()  returns  the  number of bytes received.  If the connection has
  2328.     been  closed,it returns 0.  Note that in this case the completion routine,
  2329.     if  specified, will  have  already  been  queued.   Otherwise, a value of
  2330.     SOCKET_ERROR  is  returned, and  a  specific  error  code  is available in
  2331.     lpErrno.   The  error  code  WSA_IO_PENDING  indicates  that the overlapped
  2332.     operation  has  been  successfully  initiated  and  that completion will be
  2333.     indicated  at  a  later  time.   Any  other  error  code  indicates that no
  2334.     overlapped operation was initiated and no completion indication will occur.
  2335.  
  2336. --*/
  2337.  
  2338.  
  2339. {
  2340.     INT ReturnValue;
  2341.  
  2342.     if (PREAPINOTIFY(( DTCODE_WSPSendTo,
  2343.                        &ReturnValue,
  2344.                        m_lib_name,
  2345.                        &s,
  2346.                        &lpBuffers,
  2347.                        &lpNumberOfBytesSent,
  2348.                        &dwFlags,
  2349.                        &lpTo,
  2350.                        &iTolen,
  2351.                        &lpOverlapped,
  2352.                        &lpCompletionRoutine,
  2353.                        &lpThreadId,
  2354.                        &lpErrno)) ) {
  2355.         return(ReturnValue);
  2356.     }
  2357.  
  2358.     ReturnValue = m_proctable->lpWSPSendTo(
  2359.         s,
  2360.         lpBuffers,
  2361.         dbBufferCount,
  2362.         lpNumberOfBytesSent,
  2363.         dwFlags,
  2364.         lpTo,
  2365.         iTolen,
  2366.         lpOverlapped,
  2367.         lpCompletionRoutine,
  2368.         lpThreadId,
  2369.         lpErrno);
  2370.  
  2371.     POSTAPINOTIFY(( DTCODE_WSPSendTo,
  2372.                     &ReturnValue,
  2373.                     m_lib_name,
  2374.                     &s,
  2375.                     &lpBuffers,
  2376.                     &lpNumberOfBytesSent,
  2377.                     &dwFlags,
  2378.                     &lpTo,
  2379.                     &iTolen,
  2380.                     &lpOverlapped,
  2381.                     &lpCompletionRoutine,
  2382.                     &lpThreadId,
  2383.                     &lpErrno));
  2384.  
  2385.     return(ReturnValue);
  2386. }
  2387.  
  2388.  
  2389. inline INT
  2390. DPROVIDER::WSPSetSockOpt(
  2391.     IN SOCKET s,
  2392.     IN INT level,
  2393.     IN INT optname,
  2394.     IN const char FAR *optval,
  2395.     IN INT optlen,
  2396.     OUT INT FAR *lpErrno
  2397.     )
  2398. /*++
  2399. Routine Description:
  2400.  
  2401.     Set a socket option.
  2402.  
  2403. Arguments:
  2404.  
  2405.     s       - A descriptor identifying a socket.
  2406.  
  2407.     level   - The  level  at  which the option is defined; the supported levels
  2408.               include   SOL_SOCKET.   (See  annex  for  more  protocol-specific
  2409.               levels.)
  2410.  
  2411.     optname - The socket option for which the value is to be set.
  2412.  
  2413.     optval  - A  pointer  to  the  buffer  in which the value for the requested
  2414.               option is supplied.
  2415.  
  2416.     optlen  - The size of the optval buffer.
  2417.  
  2418.     lpErrno - A pointer to the error code.
  2419.  
  2420. Return Value:
  2421.  
  2422.     If  no  error  occurs, WSPSetSockOpt()  returns  0.  Otherwise, a value of
  2423.     SOCKET_ERROR  is  returned, and  a  specific  error  code  is available in
  2424.     lpErrno.
  2425.  
  2426. --*/
  2427. {
  2428.     INT ReturnValue;
  2429.  
  2430.     if (PREAPINOTIFY(( DTCODE_WSPSetSockOpt,
  2431.                        &ReturnValue,
  2432.                        m_lib_name,
  2433.                        &s,
  2434.                        &level,
  2435.                        &optname,
  2436.                        &optval,
  2437.                        &optlen,
  2438.                        &lpErrno)) ) {
  2439.         return(ReturnValue);
  2440.     }
  2441.  
  2442.     ReturnValue = m_proctable->lpWSPSetSockOpt(
  2443.         s,
  2444.         level,
  2445.         optname,
  2446.         optval,
  2447.         optlen,
  2448.         lpErrno);
  2449.  
  2450.     POSTAPINOTIFY(( DTCODE_WSPSetSockOpt,
  2451.                     &ReturnValue,
  2452.                     m_lib_name,
  2453.                     &s,
  2454.                     &level,
  2455.                     &optname,
  2456.                     &optval,
  2457.                     &optlen,
  2458.                     &lpErrno));
  2459.  
  2460.     return(ReturnValue);
  2461.  
  2462. }
  2463.  
  2464.  
  2465.  
  2466. inline INT
  2467. DPROVIDER::WSPShutdown(
  2468.     IN SOCKET s,
  2469.     IN INT how,
  2470.     OUT INT FAR *lpErrno
  2471.     )
  2472. /*++
  2473. Routine Description:
  2474.  
  2475.     Disable sends and/or receives on a socket.
  2476.  
  2477. Arguments:
  2478.  
  2479.     s       - A descriptor identifying a socket.
  2480.  
  2481.     how     - A  flag  that describes what types of operation will no longer be
  2482.               allowed.
  2483.  
  2484.     lpErrno - A pointer to the error code.
  2485.  
  2486. Return Value:
  2487.  
  2488.     If  no  error  occurs, WSPShutdown()  returns  0.   Otherwise, a value of
  2489.     SOCKET_ERROR  is  returned, and  a  specific  error  code  is available in
  2490.     lpErrno.
  2491.  
  2492. --*/
  2493. {
  2494.     INT ReturnValue;
  2495.  
  2496.     if (PREAPINOTIFY(( DTCODE_WSPShutdown,
  2497.                        &ReturnValue,
  2498.                        m_lib_name,
  2499.                        &s,
  2500.                        &how,
  2501.                        &lpErrno)) ) {
  2502.         return(ReturnValue);
  2503.     }
  2504.  
  2505.     ReturnValue = m_proctable->lpWSPShutdown(
  2506.         s,
  2507.         how,
  2508.         lpErrno);
  2509.  
  2510.     POSTAPINOTIFY(( DTCODE_WSPShutdown,
  2511.                     &ReturnValue,
  2512.                     m_lib_name,
  2513.                     &s,
  2514.                     &how,
  2515.                     &lpErrno));
  2516.  
  2517.     return(ReturnValue);
  2518. }
  2519.  
  2520.  
  2521.  
  2522. inline INT
  2523. DPROVIDER::WSPSocket(
  2524.     IN int af,
  2525.     IN int type,
  2526.     IN int protocol,
  2527.     IN LPWSAPROTOCOL_INFOW lpProtocolInfo,
  2528.     IN GROUP g,
  2529.     IN DWORD dwFlags,
  2530.     OUT INT FAR *lpErrno
  2531.     )
  2532. /*++
  2533. Routine Description:
  2534.  
  2535.     Initialize  internal  data  and  prepare sockets for usage.  Must be called
  2536.     before any other socket routine.
  2537.  
  2538. Arguments:
  2539.  
  2540.     lpProtocolInfo - Supplies  a pointer to a WSAPROTOCOL_INFOA struct that
  2541.                      defines  the characteristics of the socket to be created.
  2542.  
  2543.     g              - Supplies  the identifier of the socket group which the new
  2544.                      socket is to join.
  2545.  
  2546.     dwFlags        - Supplies the socket attribute specification.
  2547.  
  2548.     lpErrno        - Returns the error code
  2549.  
  2550. Return Value:
  2551.  
  2552.     WSPSocket() returns zero if successful.  Otherwise it returns an error code
  2553.     as outlined in the SPI.
  2554.  
  2555. --*/
  2556. {
  2557.     INT ReturnValue;
  2558.  
  2559.     // Debug/Trace stuff
  2560.     if (PREAPINOTIFY(( DTCODE_WSPSocket,
  2561.                        &ReturnValue,
  2562.                        m_lib_name,
  2563.                        &af,
  2564.                        &type,
  2565.                        &protocol,
  2566.                        &lpProtocolInfo,
  2567.                        &g,
  2568.                        &dwFlags,
  2569.                        &lpErrno)) ) {
  2570.         return(ReturnValue);
  2571.     }
  2572.     assert(m_proctable->lpWSPSocket);
  2573.  
  2574.     // Actual code...
  2575.     ReturnValue = m_proctable->lpWSPSocket(
  2576.         af,
  2577.         type,
  2578.         protocol,
  2579.         lpProtocolInfo,
  2580.         g,
  2581.         dwFlags,
  2582.         lpErrno);
  2583.  
  2584.  
  2585.     // Debug/Trace stuff
  2586.     POSTAPINOTIFY(( DTCODE_WSPSocket,
  2587.                     &ReturnValue,
  2588.                     m_lib_name,
  2589.                     &af,
  2590.                     &type,
  2591.                     &protocol,
  2592.                     &lpProtocolInfo,
  2593.                     &g,
  2594.                     &dwFlags,
  2595.                     &lpErrno));
  2596.  
  2597.     return(ReturnValue);
  2598. }
  2599.  
  2600.  
  2601.  
  2602.  
  2603. inline INT
  2604. DPROVIDER::WSPStringToAddress(
  2605.     IN     LPWSTR AddressString,
  2606.     IN     INT AddressFamily,
  2607.     IN     LPWSAPROTOCOL_INFOW lpProtocolInfo,
  2608.     OUT    LPSOCKADDR lpAddress,
  2609.     IN OUT LPINT lpAddressLength,
  2610.     IN OUT LPINT lpErrno )
  2611. /*++
  2612.  
  2613. Routine Description:
  2614.  
  2615.     WSPStringToAddress() converts a human-readable string to a socket address
  2616.     structure (SOCKADDR) suitable for pass to Windows Sockets routines which
  2617.     take such a structure.  If the caller wishes the translation to be done by
  2618.     a particular provider, it should supply the corresponding WSAPROTOCOL_INFO
  2619.     struct in the lpProtocolInfo parameter.
  2620.  
  2621. Arguments:
  2622.  
  2623.     AddressString - points to the zero-terminated human-readable string to
  2624.                     convert.
  2625.  
  2626.     AddressFamily - the address family to which the string belongs.
  2627.  
  2628.     lpProtocolInfo - (optional) the WSAPROTOCOL_INFO struct for a particular
  2629.                      provider.
  2630.  
  2631.     Address - a buffer which is filled with a single SOCKADDR structure.
  2632.  
  2633.     lpAddressLength - The length of the Address buffer.  Returns the size of
  2634.                       the resultant SOCKADDR structure.
  2635.  
  2636. Return Value:
  2637.  
  2638.     The return value is 0 if the operation was successful.  Otherwise the value
  2639.     SOCKET_ERROR is returned.
  2640.  
  2641. --*/
  2642. {
  2643.      INT ReturnValue;
  2644.  
  2645.     if (PREAPINOTIFY(( DTCODE_WSPStringToAddress,
  2646.                        &ReturnValue,
  2647.                        m_lib_name,
  2648.                        &AddressString,
  2649.                        &AddressFamily,
  2650.                        &lpProtocolInfo,
  2651.                        &lpAddress,
  2652.                        &lpAddressLength,
  2653.                        &lpErrno)) ) {
  2654.         return(ReturnValue);
  2655.     }
  2656.  
  2657.     ReturnValue = m_proctable->lpWSPStringToAddress(
  2658.         AddressString,
  2659.         AddressFamily,
  2660.         lpProtocolInfo,
  2661.         lpAddress,
  2662.         lpAddressLength,
  2663.         lpErrno);
  2664.  
  2665.  
  2666.     POSTAPINOTIFY(( DTCODE_WSPStringToAddress,
  2667.                     &ReturnValue,
  2668.                     m_lib_name,
  2669.                     &AddressString,
  2670.                     &AddressFamily,
  2671.                     &lpProtocolInfo,
  2672.                     &lpAddress,
  2673.                     &lpAddressLength,
  2674.                     &lpErrno));
  2675.  
  2676.     return(ReturnValue);
  2677. }
  2678.  
  2679. inline INT
  2680. DPROVIDER::TransmitFile (
  2681.     IN SOCKET hSocket,
  2682.     IN HANDLE hFile,
  2683.     IN DWORD nNumberOfBytesToWrite,
  2684.     IN DWORD nNumberOfBytesPerSend,
  2685.     IN LPOVERLAPPED lpOverlapped,
  2686.     IN LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers,
  2687.     IN DWORD dwReserved,
  2688.     OUT LPINT lpErrno
  2689.     )
  2690. {
  2691.     if (m_transmitfile) {
  2692.         if (m_transmitfile(
  2693.                 hSocket,
  2694.                 hFile,
  2695.                 nNumberOfBytesToWrite,
  2696.                 nNumberOfBytesPerSend,
  2697.                 lpOverlapped,
  2698.                 lpTransmitBuffers,
  2699.                 dwReserved))
  2700.             return NO_ERROR;
  2701.         else {
  2702.             *lpErrno = GetLastError ();
  2703.             return SOCKET_ERROR;
  2704.         }
  2705.     }
  2706.     else {
  2707.         *lpErrno = WSAEOPNOTSUPP;
  2708.         return SOCKET_ERROR;
  2709.     }
  2710. }
  2711.  
  2712. inline INT
  2713. DPROVIDER::AcceptEx (
  2714.     IN SOCKET sListenSocket,
  2715.     IN SOCKET sAcceptSocket,
  2716.     IN PVOID lpOutputBuffer,
  2717.     IN DWORD dwReceiveDataLength,
  2718.     IN DWORD dwLocalAddressLength,
  2719.     IN DWORD dwRemoteAddressLength,
  2720.     OUT LPDWORD lpdwBytesReceived,
  2721.     IN LPOVERLAPPED lpOverlapped,
  2722.     OUT LPINT    lpErrno
  2723.     )
  2724. {
  2725.     if (m_acceptex) {
  2726.         if (m_acceptex (
  2727.                 sListenSocket,
  2728.                 sAcceptSocket,
  2729.                 lpOutputBuffer,
  2730.                 dwReceiveDataLength,
  2731.                 dwLocalAddressLength,
  2732.                 dwRemoteAddressLength,
  2733.                 lpdwBytesReceived,
  2734.                 lpOverlapped))
  2735.             return NO_ERROR;
  2736.         else {
  2737.             *lpErrno = GetLastError ();
  2738.             return SOCKET_ERROR;
  2739.         }
  2740.     }
  2741.     else  {
  2742.         *lpErrno = WSAEOPNOTSUPP;
  2743.         return SOCKET_ERROR;
  2744.     }
  2745. }
  2746.  
  2747.  
  2748.  
  2749.  
  2750.  
  2751. #endif
  2752.